#include "stdio.h"
#include "arm_const_structs.h"
#include "transform_functions.h"


#define Q15_ONE (32768)
#define Q16_ONE (65536)


float32_t hamming_window[64] =
{
	0.08000000, 0.08000000, 0.08941623, 0.08941623, 0.11727941, 0.11727941, 0.16244882, 0.16244882, 
	0.22307522, 0.22307522, 0.29667656, 0.29667656, 0.38023958, 0.38023958, 0.47034322, 0.47034322, 
	0.56329862, 0.56329862, 0.65530016, 0.65530016, 0.74258131, 0.74258131, 0.82156875, 0.82156875, 
	0.88902874, 0.88902874, 0.94219944, 0.94219944, 0.97890406, 0.97890406, 0.99763989, 0.99763989, 
	0.99763989, 0.99763989, 0.97890406, 0.97890406, 0.94219944, 0.94219944, 0.88902874, 0.88902874, 
	0.82156875, 0.82156875, 0.74258131, 0.74258131, 0.65530016, 0.65530016, 0.56329862, 0.56329862, 
	0.47034322, 0.47034322, 0.38023958, 0.38023958, 0.29667656, 0.29667656, 0.22307522, 0.22307522, 
	0.16244882, 0.16244882, 0.11727941, 0.11727941, 0.08941623, 0.08941623, 0.08000000, 0.08000000
};
uint16_t hamming_window_Q16[64];


//实部,虚部,实部,虚部...
float32_t input_float[32*2] = 
{
     0.33688039, 0.27576947, 0.99445967, 0.76294948,
     0.70402479, 0.07054292, 0.44225181, 0.24120408,
     0.48560569, 0.12177725, 0.18824296, 0.87400103,
     0.38203619, 0.13971502, 0.21115924, 0.16845203,
     0.86836398, 0.44339537, 0.91344222, 0.18359897,
     0.66934949, 0.953202,   0.98336128, 0.51880677,
     0.7314163, 0.41706149,  0.61245894, 0.02790013,
     0.20736128, 0.37723832, 0.27917189, 0.33977751,
     0.79783386, 0.55812144, 0.51681, 0.59290067,
     0.33205087, 0.87387007, 0.19170072, 0.18220524,
     0.39737357, 0.69744759, 0.28801394, 0.82422595,
     0.27648721, 0.49734381, 0.63294795, 0.50805464,
     0.67525571, 0.15635329, 0.44887195, 0.33571562,
     0.71634485, 0.82814263, 0.49399417, 0.34142172,
     0.39951166, 0.56482186, 0.51141589, 0.57559398,
     0.39054342, 0.41560708, 0.65810208, 0.55645494
};

int main(void)
{
    int16_t input_Q15[32*2];
    int32_t mul_Q31[64];

    for(int i=0; i<64; i++)
    {
	    hamming_window_Q16[i] = round(hamming_window[i] * Q16_ONE);
	    input_Q15[i] = round(input_float[i] * Q15_ONE);
	    mul_Q31[i] = hamming_window_Q16[i] * input_Q15[i];
    }

    arm_cfft_q31(&arm_cfft_sR_q31_len32, mul_Q31, 0, 1);

    for (int i = 0; i < 32; i++)
    {
       printf("%4d: %.8f, %.8f\r\n", i, mul_Q31[2*i]/67108864.0 , mul_Q31[2*i+1]/67108864.0);
    }
    
    return 0;
}


